#ifndef _PRIORITY_QUEUE_H_
#define _PRIORITY_QUEUE_H_

#include <util.h>

typedef struct
{
    int *a;
    int count;
    int size;
} PQ;

#define LEFT(i)		( (((i) << 1) + 1) )
#define RIGHT(i)	(((i) << 1) + 2)
// WRONG!!!
// #define PARENT(i)	( ( (i) & (~(0x1)) ) / 2)
#define PARENT(i)	( ((i) - 1 ) / 2)

/*
int maximum(int a[], int *max);
int extract_max(int a[], int *max);
int insert(int a[], int maxLen, int key);
void max_heapify(int a[], int i);
void increase_key(int a[], int i, int k);
int build_max_pq(int a[], int hsize, int maxLen);
*/
int init_max_pq(PQ *pq, int size);
void finalize_max_pq(PQ *pq);
int isfull(PQ *pq);
int isempty(PQ *pq);
int maximum(PQ * pq, int *max);
int extract_max(PQ *pq, int *max);
int insert(PQ *pq, int key);
void max_heapify(int a[], int hsize, int i);
int increase_key(PQ *pq, int i, int key);
int pq_del(PQ *pq, int i);
int build_max_pq(PQ *pq, int a[], int n);
/*int build_max_pq(int a[], int hsize, int maxLen);*/

#endif
